package com.hl.mapper;

import com.hl.pojo.Article;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

@Repository
public interface ArticleMapper {
    public List<Article> getAllArticleMessage();
    public List<Article> searchArticle(String keyword);
    List<Map<String,Object>> souSuoArticleMessage(Map<String,Object> map);
    Integer xinzengArticleMessage();

    @Select("select id from articlecategory where category_name = #{category_name}")
    Integer searchByCategory_name(String category_name);

    @Insert("INSERT INTO article(article_name,article_intro,category_id,img_path) VALUES (#{article_name},#{article_intro},#{category_name},#{img_path})")
    Integer xinZengArticleMessage(Map<String,Object> map);

    @Delete("DELETE FROM article WHERE id = #{id}")
    Integer shanChuArticleMessage(Integer id);

    @Update("UPDATE article SET article_name = #{article_name},article_intro = #{article_intro},img_path = #{img_path},category_id = #{category_name} where id = #{id}")
    Integer xiuGaiArticleMessage(Map<String,Object> map);

    @Insert("INSERT INTO article(img_path) VALUES (#{img_path})")
    Integer queDingShangChuan(String img_path);
}
